package xyz.dagoose.contacts

/*
 java new 一个引用数据类型，才能在堆里产生一个新的内存
 对比python中的copy.copy()、copy.deepcopy()
 */
public class arrExcr2 {
	
	public static void main(String[] args) {
		int[] arr = new int[12];
		for(int i=0;i<arr.length;i++){
			arr[i] = (int)(1+Math.random()*10);
		}
		int[] arr2 = arr;
		int[] arr3 = new int [arr.length];
		for(int i=0;i<arr.length;i++){
			arr3[i] = arr[i];
		}
		
		System.out.print("变换前*************\n");
		for(int i=0;i<arr.length;i++){
			System.out.print(arr[i]+"  ");
		}
		System.out.print("\n");
		for(int i=0;i<arr.length;i++){
			System.out.print(arr2[i]+"  ");
		}
		System.out.print("\n");
		for(int i=0;i<arr.length;i++){
			System.out.print(arr3[i]+"  ");
		}
		System.out.print("\n");
		
		
		for(int i=0;i<arr.length;i+=2){
			arr[i] = i;
		}

		System.out.print("变换后*************\n");
		for(int i=0;i<arr.length;i++){
			System.out.print(arr[i]+"  ");
		}
		System.out.print("\n");
		for(int i=0;i<arr.length;i++){
			System.out.print(arr2[i]+"  ");
		}
		System.out.print("\n");
		for(int i=0;i<arr.length;i++){
			System.out.print(arr3[i]+"  ");
		}
		System.out.print("\n");
		
		
	}
}
